package com.lonely.fx;

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.stage.Stage;

/**
 * @date: 2022-06-15 15:27
 * @author: ztkj-hzb
 * @description: 监听器设置
 **/
public class ListenerSettingMain extends Application {

    public static void main(String[] args) {
        launch(args);
    }


    /**
     *
     */
    @Override
    public void start(Stage primaryStage) throws Exception {

        //宽度监听
        primaryStage.widthProperty().addListener((observable, oldValue, newValue) -> System.out.printf("宽度在变化：%s -- %s%n", oldValue, newValue));

        //高度监听
        primaryStage.heightProperty().addListener((observable, oldValue, newValue) -> System.out.printf("高度在变化：%s -- %s%n", oldValue, newValue));

        //x坐标监听
        primaryStage.xProperty().addListener((observable, oldValue, newValue) -> System.out.printf("x坐标在变化：%s -- %s%n", oldValue, newValue));

        //y坐标监听
        primaryStage.yProperty().addListener((observable, oldValue, newValue) -> System.out.printf("y坐标在变化：%s -- %s%n", oldValue, newValue));

        primaryStage.show();
    }
}
